CFLAGS = -Wall -fpic -coverage -lm
GFLAGS = -fprofile-arcs -ftest-coverage

testcards: testcardfunction.c dominion.o
	gcc -o testcards -g testcardfunction.c dominion.o rngs.o $(CFLAGS)

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

testUpdateCoins: testUpdateCoins.c dominion.o rngs.o
	gcc -o testUpdateCoins -g  testUpdateCoins.c dominion.o rngs.o $(CFLAGS)
	
unittest1: unittest1.c dominion.o
	gcc -o unittest1 -g unittest1.c dominion.o rngs.o $(CFLAGS)

unittest2: unittest2.c dominion.o
	gcc -o unittest2 -g unittest2.c dominion.o rngs.o $(CFLAGS)

unittest3: unittest3.c dominion.o
	gcc -o unittest3 -g unittest3.c dominion.o rngs.o $(CFLAGS)
	
unittest4: unittest4.c dominion.o rngs.o
	gcc -o unittest4 -g unittest4.c dominion.o rngs.o $(CFLAGS)
	
cardtest1: cardtest1.c dominion.o
	gcc $(GFLAGS) -o cardtest1 -g cardtest1.c dominion.o rngs.o $(CFLAGS)

cardtest2: cardtest2.c dominion.o
	gcc $(GFLAGS) -o cardtest2 -g cardtest2.c dominion.o rngs.o $(CFLAGS)
	
cardtest3: cardtest3.c dominion.o
	gcc $(GFLAGS) -o cardtest3 -g cardtest3.c dominion.o rngs.o $(CFLAGS)
	
cardtest4: cardtest4.c dominion.o
	gcc $(GFLAGS) -o cardtest4 -g cardtest4.c dominion.o rngs.o $(CFLAGS)
	
unittest: unittest1 unittest2 unittest3 unittest4

cardtest: cardtest1 cardtest2 cardtest3 cardtest4

unittestresults.out:
	make cardtest
	make unittest
	cardtest1
	cardtest2
	cardtest3
	cardtest4
	unittest1
	unittest2
	unittest3
	unittest4
	gcov cardtest1 cardtest2 cardtest3 cardtest4 unittest1 unittest2 unittest3 unittest4 > unittestresults.out
	
cleantest:
	rm -f *.gcno unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 unittestresults.out
	
testdom: testdominion.c dominion.o FORCE
	gcc $(GFLAGS) -o testdom -g testdominion.c dominion.o rngs.o $(CFLAGS)
	make testdominion.out
	make gameResults.out
	
FORCE: 
testdominion.out: FORCE
	gcov testdom > testdominion.out
	
gameResults.out: FORCE
	rm -f gameResults.out
	testdom > gameResults.out

testdom_clean:
	rm -f *.gnco testdom testdominion.out gameResults.out
	
random_a: randomtestadventurer.c dominion.o
	gcc $(GFLAGS) -o random_a -g randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	random_a
	gcov random_a > randomtestadventurer.out
	
random_t: randomtestcard.c dominion.o
	gcc $(GFLAGS) -o random_t -g randomtestcard.c dominion.o rngs.o $(CFLAGS)
	random_t
	gcov random_t > randomtestcard.out
	
cleanrandom:
	rm -f *.gcno random_a random_t randomtestadventurer.out randomtestcard.out
	
all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe *.gcov *.gcda *.gcno *.so
